<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Admin\Rule;

class RuleController extends Controller
{
    public function getList(Request $request)
    {
        $pageSize = $request['pageSize'];

        $ruleModel = new Rule;
        $data = $ruleModel->getList($pageSize);

        return $data;
    }

    public function handle(Request $request)
    {
        $data = [];
        $data['id'] = $request['id'];
        $data['title'] = $request['title'];
        $data['url'] = $request['url'];
        $data['menu_id'] = empty($request['menu_id']) ? 0 : $request['menu_id'];
        $data['parent_menu_id'] = empty($request['parent_menu_id']) ? 0 : $request['parent_menu_id'];

        $ruleModel = new Rule;
        $result = $ruleModel->handle($data);

        return $result;
    }

    public function delete(Request $request)
    {
        $id = $request['id'];
        $ruleModel = new Rule;
        $ruleModel = new Rule;
        $result = $ruleModel->deleteAction($id);

        return $result;
    }
}
